package com.cxh.rmsq.ui.adapter.self

import android.content.Intent
import android.text.TextUtils
import android.widget.TextView
import androidx.core.view.isVisible
import com.blankj.utilcode.util.TimeUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cxh.rmsq.R
import com.cxh.rmsq.common.IntentExtra
import com.cxh.rmsq.db.model.CommunityContent
import com.cxh.rmsq.db.model.InviteChildren
import com.cxh.rmsq.db.model.RankListBean
import com.cxh.rmsq.ui.activity.self.CommentDetailActivity
import com.cxh.rmsq.ui.activity.self.LookUserDetailActivity2
import com.cxh.rmsq.ui.widget.SelectableRoundedImageView
import com.cxh.rmsq.utils.loadImage


/**
 *
 */
class RankListAdapter(type: Int) :
    BaseQuickAdapter<RankListBean, BaseViewHolder>(R.layout.item_invite_list),
    LoadMoreModule {

    override fun convert(holder: BaseViewHolder, item: RankListBean) {
        with(holder) {

            getView<TextView>(R.id.tv_text).isVisible = true
            setText(R.id.tv_name, item.nickname)

            if (!TextUtils.isEmpty(item.currentUserAmountEarned)) {
                setText(R.id.tv_time, item.currentUserAmountEarned + "元")
            } else {
                setText(R.id.tv_time, "0元")
            }

            loadImage(
                item.avatar,
                holder.getView<SelectableRoundedImageView>(R.id.siv_header)
            )
            holder.itemView.setOnClickListener {
                val intent = Intent(context, LookUserDetailActivity2::class.java)
                intent.putExtra(IntentExtra.STR_TARGET_ID, item.userId.toString())
                intent.putExtra("isContact", "1")
                context.startActivity(intent)
            }
        }
    }

}